<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background: #00ff44;
            position: fixed;
            left: 0px;
            top: 100px;
        }
    </style>
    <script>
        window.onload = function () {
            var oBox = document.getElementById('box');
            var iLeft = 0;
            var iSpeed = 5;

            setInterval(fnMove, 30);

            function fnMove() {
                iLeft += iSpeed;
                if (iLeft > 1150) {
                    iSpeed = -5;
                }
                if (iLeft < 0) {
                    iSpeed = 5;
                }
                oBox.style.left = iLeft + 'px';
            }
        }
    </script>
</head>
<body>
    <div class="box" id="box"></div>
</body>
</html>